package db_main

import (
	"errors"
	"fmt"
	"gorm.io/gorm"
	"longmen/server/pkg/common/helper/util"
	"longmen/server/pkg/db/mysql"
	"longmen/server/pkg/db/mysql/models/models_main"
)

func GetAndroidPatchParam(param map[string]interface{}, order string) ([]*models_main.AppPatch, error) {
	var (
		err             error
		fName           = "GetAndroidPatchParam"
		appPatchEntitys = make([]*models_main.AppPatch, 0)
		table           = mysql.GetRTable(&models_main.AppPatch{})
	)

	mysql.Condition(table, param, "", order, 0, 0)

	if err = table.Find(&appPatchEntitys).Error; errors.Is(err, gorm.ErrRecordNotFound) {
		err = nil
	}
	if err != nil {
		err = fmt.Errorf("%s %s", util.Convert(fName), err.Error())
	}

	return appPatchEntitys, err
}
